<?php

namespace app\controller\system;

use app\BaseController;
use app\model\StationOilCategory;
use think\response\Json;

class OilCategory extends BaseController
{
    public function save(): Json
    {
        return $this->handle(function () {
            return $this->app->make(StationOilCategory::class)->saveData();
        });
    }

    public function lst(): Json
    {
        return $this->handle(function () {
            return $this->app->make(StationOilCategory::class)->pageData();
        });
    }

    public function detail(): Json
    {
        return $this->handle(function () {
            $param = request()->param();
            return $this->app->make(StationOilCategory::class)->where("id", $param['id'])->find()->toArray();
        });
    }

    public function search(): Json
    {
        return $this->handle(function () {
            return $this->app->make(StationOilCategory::class)->where('state', 1)->column("id,name");
        });
    }
}
